#include "TcpServer.hpp"
#include "Dict.hpp"

void Usage(std::string proc)
{
    std::cerr << "Usage: " << proc << " <port>" << std::endl;
}

int main(int argc, char* argv[])
{

    if(argc != 2)
    {
        Usage(argv[0]);
    }
    uint16_t port = std::stoi(argv[1]);

    // 单体模块
    Dict d;
    d.LoadDict();


    std::unique_ptr<TcpServer> tsvr = std::make_unique<TcpServer>(port, [&d](const std::string& word, InerAddr& addr){
        return d.Translate(word, addr);
    });
    tsvr->Init();
    tsvr->Run();

    return 0;
}